package cn.hfatec.shms.web.members.linGrade.service;

import java.util.List;
import java.util.HashMap;


import cn.hfatec.shms.advice.annotation.OracleDataSource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.hfatec.base.BaseDao;
import cn.hfatec.Page;
import cn.hfatec.Table;
import cn.hfatec.shms.web.members.linGrade.model.LinGrade;
import cn.hfatec.shms.web.members.linGrade.dao.LinGradeDao;
import cn.hfatec.shms.web.members.linGrade.model.LinGradeParams;

import javax.annotation.Resource;



/**
 *
 * @author hfatec
 * @version 1.0
 *
 * the JAVA code is generate by middlegen
 *
 */
@Service("LinGradeService")
public class LinGradeService {

    public static final String BEAN_ID = "LinGradeService";

    //注入Dao层
    @Resource(name = "LinGradeDao")
    private LinGradeDao linGradeDao;

    //注入BaseDao
    @Resource(name = "BaseDao")
    private BaseDao baseDao;

    /**
     *
     * 查询数据
     *
     * @param linGradeParams
     * @param page
     *
     */
    @Transactional
    @OracleDataSource
    public Table queryLinGradeTable(LinGradeParams linGradeParams, Page page){
        HashMap<String, Object> params = new HashMap<String, Object>();
        //如果Page为空
        if(null == page) page = new Page();
        //起始点
        int offset = page.getPageSize() * (page.getCurrentPage() - 1);
        //查询的记录数
        int limit = offset+10;
        linGradeParams.setStartPage(offset);
        linGradeParams.setEndPage(limit);
        LinGrade linGrade=getLinGrade();
        page.setTotalPage(linGrade.getTotal()/10+1);
        page.setTotalSize(linGrade.getTotal());
        params.put("params", linGradeParams);
        return baseDao.queryTableByPageOracle("queryLinGrade", params, page);
    }


    /**
     *
     * 根据ID获取数据
        */
    @Transactional
    public LinGrade getLinGrade() {

        return linGradeDao.getLinGradeById();
    }
}